/**************************************************************************
 Name         : pvrvea.h
 Title        : pvrvea.h
 Author       : PowerVR
 Created      : March 2005

 Copyright    : 2005 by Imaginationc Technologies Limited. All rights reserved.
              : No part of this software, either material or conceptual 
              : may be copied or distributed, transmitted, transcribed,
              : stored in a retrieval system or translated into any 
              : human or computer language in any form by any means,
              : electronic, mechanical, manual or other-wise, or 
              : disclosed to third parties without the express written
              : permission of Imagination Technologies Limited, Unit 8, HomePark
              : Industrial Estate, King's Langley, Hertfordshire,
              : WD4 8LZ, U.K.

 Description  : MVEA API Header file

 Platform     : Generic
 Version	  : $Revision: 1.17 $
 Modifications	: 
 $Log: PVRVEA.h,v $

  --- Revision Logs Removed --- 

  --- Revision Logs Removed --- 

  --- Revision Logs Removed --- 

  --- Revision Logs Removed --- 

  --- Revision Logs Removed --- 

  --- Revision Logs Removed --- 

  --- Revision Logs Removed --- 

  --- Revision Logs Removed --- 

  --- Revision Logs Removed --- 

  --- Revision Logs Removed --- 

  --- Revision Logs Removed --- 

  --- Revision Logs Removed --- 

  --- Revision Logs Removed --- 

  --- Revision Logs Removed --- 

  --- Revision Logs Removed --- 

  --- Revision Logs Removed --- 

*******************************************************************************/


#ifndef _PVR_MVEA_
#define _PVR_MVEA_

#include "img_types.h"
#include "PVRReturnCode.h"
#include "PVRCodecAPI.h"

typedef enum
{
	PVR_MB_MODE_P_16 =		0,
	PVR_MB_MODE_P_8 =		1,
	PVR_MB_MODE_P_4 =		2,
	PVR_MB_MODE_INTRA16 =	3,
	PVR_MB_MODE_INTRA4 =	4,
	PVR_MB_MODE_NOT_CODED = 5
}MB_MODE;



typedef struct
{
	/* Vectors, Coding modes, coded residual and QP*/
	union 
	{
		struct
		{
			MB_MODE		aeCodingMode[4];		/* Denotes I/P block and also block size */
			IMG_INT16	*aiVectors;			/* 16 pairs of x,y vectors, one for each 4x4 block*/
			IMG_INT		aiIntraPredModes[16];	/* The numeric value that represents the intra prediction mode for the relevant block, according to the H264 spec*/
			IMG_INT		iChromaIntraPredMode;	/* The chroma block pred mode*/
			IMG_UINT32	ui32CBP;				

			IMG_UINT32	ui32SadCost;
			IMG_BYTE	byQP;
			IMG_UINT32	ui32ResidualOffset;		/* The offset into the residual buffer of this macroblocks coded residual data, this is in Residual run length pairs*/
		}H264;
		struct
		{
			MB_MODE		aeCodingMode[4];		/* Denotes I/P block and also block size */
			IMG_INT		aiVectors[8];			/* 16 pairs of x,y vectors, one for each 4x4 block*/
			IMG_UINT32	ui32CBP;				
			IMG_UINT32	ui32SadCost;
			IMG_BYTE	byQp;
			IMG_UINT32	ui32ResidualOffset;		/* The offset into the residual buffer of this macroblocks coded residual data, this is in Residual run length pairs*/
		}MPEG4;
	}EncoderData;
}PVRMVEA_MACROBLOCKDATA;


typedef struct {
/* Make sure it is packed to be the correct size otherwise our pointer arithmatic will be out*/
#pragma pack(push , allignment)
#pragma	pack(1)
	IMG_INT16 byLevel;
	IMG_BYTE byRun;
#pragma pack( pop , allignment )
}PVRMVEA_RLEPAIR;


typedef struct
{
	PVR_SURFACE		psTargetSurface;
	PVR_SURFACE		psReferenceSurface;
	PVR_SURFACE		psDestSurface;
	IMG_BOOL		bIsInter;
	IMG_BOOL		bDeblockFrame;
	IMG_INT16		iFrameID;
	PVR_AC_CONTROL  eACControl;
}PVRMVEA_FRAMEPARAMS;


typedef struct
{
	IMG_UINT32 ui32Count;
	PVRMVEA_MACROBLOCKDATA *psMacroblockData;
	PVRMVEA_RLEPAIR *psCodedResidual;
}PVRMVEA_CODED_OUTPUT;





typedef PVRRC (*FNDATAREADY)(IMG_UINT32 ,  IMG_VOID*);

#ifdef __cplusplus
extern "C" {  
#endif
/***********************************************************************************
 Function Name      : PVRVEASetupFrameParams
 Inputs             : hHandle,psFrameParams
 Outputs            : 
 Returns            : PVRRC
 Description        : Setup the frame parameters for the encoder
************************************************************************************/
PVRCODEC_API PVRRC PVRVEASetupFrameParams(/*in */	PVR_INSTANCE		hInstance,
										  /*in */	PVRMVEA_FRAMEPARAMS* psFrameParams);

typedef PVRRC (*fnPVRVEASetupFrameParams)(/*in */	PVR_INSTANCE		hInstance,
											/*in */	PVRMVEA_FRAMEPARAMS* psFrameParams);

/***********************************************************************************
 Function Name      : PVRVEAChangeQP
 Inputs             : hHandle,byNewQP
 Outputs            : 
 Returns            : PVRRC
 Description        : Changes the QP that the encoder will use for future macroblocks
					: This will not take effect for several macroblocks
 ************************************************************************************/
PVRCODEC_API PVRRC PVRVEAChangeQP(	/*in */	PVR_INSTANCE	hInstance,
									/*in */	IMG_BYTE		byNewQP);

typedef PVRRC (*fnPVRVEAChangeQP)(	/*in */	PVR_INSTANCE	hInstance,
									/*in */	IMG_BYTE		byNewQP);

/***********************************************************************************
 Function Name      : PVRVEAStartEncode
 Inputs             : hHandle,iXPos,iYPos,iNumMacroblocks
 Outputs            : 
 Returns            : PVRRC
 Description        : Start the encode process for the given slice.
 ************************************************************************************/
PVRCODEC_API PVRRC PVRVEAStartEncode(	/*in */	PVR_INSTANCE	hInstance,
										/*in */	IMG_INT16		iXPos,
										/*in */	IMG_INT16		iYPos, 
										/*in */	IMG_INT			iNumMacroblocks);

typedef PVRRC (*fnPVRVEAStartEncode)(	/*in */	PVR_INSTANCE	hInstance,
										/*in */	IMG_INT16		iXPos,
										/*in */	IMG_INT16		iYPos, 
										/*in */	IMG_INT			iNumMacroblocks);

/***********************************************************************************
 Function Name      : PVRVEASetDataReadyCallBack
 Inputs             : hHandle,fnDataReadyCallBack,pContext
 Outputs            : 
 Returns            : PVRRC
 Description        : 
 ************************************************************************************/
PVRCODEC_API PVRRC PVRVEASetDataReadyCallBack(	/*in */	PVR_INSTANCE	hInstance,
												/*in */	FNDATAREADY		fnDataReadyCallBack, 
												/*in */	IMG_VOID*		pContext);

typedef PVRRC (*fnPVRVEASetDataReadyCallBack)(	/*in */	PVR_INSTANCE	hInstance,
												/*in */	FNDATAREADY		fnDataReadyCallBack, 
												/*in */	IMG_VOID*		pContext);

/***********************************************************************************
 Function Name      : PVRVEAGetStatus
 Inputs             : hInstance,
 Outputs            : *pui32Status ,*pui32BlocksReady
 Returns            : PVRRC
 Description        : Get the current encode status
 ************************************************************************************/
PVRCODEC_API PVRRC PVRVEAGetStatus(	/*in */	PVR_INSTANCE	hInstance, 
									/*out*/	IMG_UINT32*		pui32Status, 
									/*out*/	IMG_UINT32*		pui32BlocksReady);

typedef PVRRC (*fnPVRVEAGetStatus)(	/*in */	PVR_INSTANCE	hInstance, 
									/*out*/	IMG_UINT32*		pui32Status, 
									/*out*/	IMG_UINT32*		pui32BlocksReady);

/***********************************************************************************
 Function Name      : PVRVEAGetData
 Inputs             : hInstance,
 Outputs            : *pui32Data
 Returns            : PVRRC
 Description        : Get what data is ready for us.
 ************************************************************************************/
PVRCODEC_API PVRRC PVRVEAGetData(	/*in */	PVR_INSTANCE	hInstance, 
									/*out*/	PVRMVEA_CODED_OUTPUT		**pui32Data);

typedef PVRRC (*fnPVRVEAGetData)(	/*in */	PVR_INSTANCE	hInstance, 
									/*out*/	PVRMVEA_CODED_OUTPUT		**pui32Data);

/***********************************************************************************
 Function Name      : PVRVEAReleaseData
 Inputs             : hInstance,*pui32Data
 Outputs            : 
 Returns            : PVRRC
 Description        : Release the data buffer after it has been used.
 ************************************************************************************/
PVRCODEC_API PVRRC PVRVEAReleaseData(	/*in */	PVR_INSTANCE	hInstance, 
										/*in */	PVRMVEA_CODED_OUTPUT		*pui32Data);

typedef PVRRC (*fnPVRVEAReleaseData)(	/*in */	PVR_INSTANCE	hInstance, 
										/*in */	PVRMVEA_CODED_OUTPUT		*pui32Data);

typedef struct
{
	fnPVRInitialise			PVRInitialise;
	fnPVRDeinitialise		PVRDeinitialise;
	fnPVRSurfaceAllocate	PVRSurfaceAllocate;
	fnPVRSurfaceAllocateRaw	PVRSurfaceAllocateRaw;
	fnPVRSurfaceSync		PVRSurfaceSync;
	fnPVRSurfaceLock		PVRSurfaceLock;
	fnPVRSurfaceUnlock		PVRSurfaceUnlock;
	fnPVRSurfaceFree		PVRSurfaceFree;

	fnPVRVEASetupFrameParams		PVRVEASetupFrameParams;
	fnPVRVEAChangeQP				PVRVEAChangeQP;
	fnPVRVEAStartEncode				PVRVEAStartEncode;
	fnPVRVEASetDataReadyCallBack	PVRVEASetDataReadyCallBack;
	fnPVRVEAGetStatus				PVRVEAGetStatus;
	fnPVRVEAGetData					PVRVEAGetData;
	fnPVRVEAReleaseData				PVRVEAReleaseData;
} PVRVEAAPI;


#ifdef __cplusplus
}
#endif



#endif
